package com.admin.scroller.photoorvideo.holders;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class PerviewHolder extends RecyclerView.ViewHolder {
    public PerviewHolder(View itemView) {
        super(itemView);
        viewSparseArray=new SparseArray<View>();
        this.currentView=itemView;
    }
    SparseArray<View> viewSparseArray;
    View currentView;


    public static PerviewHolder getHolder(Context context, ViewGroup parent, int type){
        View view= LayoutInflater.from(context).inflate(type,parent,false);
        return new PerviewHolder(view);
    }

    public <T extends View> T getView(int viewId){
        View view=viewSparseArray.get(viewId);
        if(view==null){
            view=currentView.findViewById(viewId);
        }
        return (T) view;
    }

}
